//#include <windows.h>
#include <winsock2.h>
#pragma  comment(lib,"WS2_32.lib")

#include "logmgr.h"

int main()
{
	WSADATA wsadata;
	SOCKET SockServ;
	SOCKET SockCli;
	SOCKADDR_IN SockaddrServ;
	SOCKADDR_IN SockaddrCli;
	int port = 8888;
	
	WSAStartup(MAKEWORD(2,2),&wsadata);

	SockServ = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
	if (INVALID_SOCKET == SockServ)
		DEBUG_PRINT("build server socket failed!\n");
	else
		DEBUG_PRINT("create server socket success!\n");

	SockaddrServ.sin_family = AF_INET;
	SockaddrServ.sin_port = htons(port);
	SockaddrServ.sin_addr.S_un.S_addr = htonl(INADDR_ANY);

	bind(SockServ,(SOCKADDR*)&SockaddrServ,
		sizeof(SockaddrServ));

	listen(SockServ,10);

	int nlen = sizeof(SockaddrCli);

	for (;;)
	{
		SockCli = accept(SockServ,
			(SOCKADDR*)&SockaddrCli , &nlen);

		closesocket(SockCli);
	}
	

	
	closesocket(SockCli);
	closesocket(SockServ);

	WSACleanup();
	

	return 0;
}